package com.kye.express.business.main.fragmentAdapter;

import android.support.v4.app.Fragment;

import com.aspsine.fragmentnavigator.FragmentNavigatorAdapter;

import com.kye.express.R;
import com.kye.express.business.found.FoundFragment;
import com.kye.express.business.home.HomeFragment;
import com.kye.express.business.service.ServiceFragment;
import com.kye.express.business.personal.PersonalFragment;
import com.kye.express.business.welfare.WelfareFragment;

/**
 * @author : Joe
 * @version : 1.0
 * @editor : Joe
 * @created : 18/12/2017
 * @updated : 18/12/2017
 * @description : <Description>
 * @update_reason : <UpdateReason>
 */

public class MainFragmentAdapter implements FragmentNavigatorAdapter {

    public final static int TAB_POSITION_HOME = 0; // 首页
    public final static int TAB_POSITION_GIFT = 1; // 礼品
    public final static int TAB_POSITION_SERVICE = 2; // 寄件
    public final static int TAB_POSITION_FOUND = 3; // 发现
    public final static int TAB_POSITION_ME = 4; // 我的

    private String[] TABS = {
            "首页",
            "礼品",
            "寄件",
            "发现",
            "我的"
    };

    private int[] mIconUnselectIds = {
            R.drawable.tab_home_unselected,
            R.drawable.tab_welfare_unselected,
            R.drawable.tab_welfare_unselected, // todo : 仅仅用来占位, 寄件点击单独处理
            R.drawable.tab_but_fx_n,
            R.drawable.tab_personal_unselected
    };

    private int[] mIconSelectIds = {
            R.drawable.tab_home_selected,
            R.drawable.tab_welfare_selected,
            R.drawable.tab_welfare_selected, // todo : 仅仅用来占位, 寄件点击单独处理
            R.drawable.tab_but_fx_s,
            R.drawable.tab_personal_selected
    };

    public MainFragmentAdapter() {

    }

    public String[] getTABS() {
        return TABS;
    }

    public int[] getmIconUnselectIds() {
        return mIconUnselectIds;
    }

    public int[] getmIconSelectIds() {
        return mIconSelectIds;
    }

    @Override
    public Fragment onCreateFragment(int position) {
        switch (position) {
            case TAB_POSITION_HOME:
                return HomeFragment.newInstance();
            case TAB_POSITION_GIFT:
                return WelfareFragment.newInstance();
            case TAB_POSITION_SERVICE:
                return ServiceFragment.newInstance();
            case TAB_POSITION_FOUND:
                return FoundFragment.newInstance();
            case TAB_POSITION_ME:
                return PersonalFragment.newInstance();
            default:
                throw new IllegalArgumentException("tab position error : " + position);
        }
    }

    @Override
    public String getTag(int i) {
        return TABS[i];
    }

    @Override
    public int getCount() {
        return TABS.length;
    }
}
